package com.zisu.aradvertising.controller;



import com.zisu.aradvertising.pojo.AdvertiserSpace;
import com.zisu.aradvertising.pojo.Result;
import com.zisu.aradvertising.service.AdvertiserSpaceService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/advertiserSpace")
public class AdvertiserSpaceController {
    @Resource
    private AdvertiserSpaceService advertiserSpaceService;

    //返回所有广告位和广告商
    @PostMapping("/findall")
    public Result<List<AdvertiserSpace>> findallConroller(@RequestParam int vid) {
        List<AdvertiserSpace> list = advertiserSpaceService.findallbyvidService(vid );
        if (list != null) {
            return Result.success(list, "返回广告位成功!");
        } else {
            return Result.error("123", "返回广告位失败!");
        }
    }

    //返回单个广告位、视频、合作信息
    @PostMapping("/findallbyapid")
    public Result<AdvertiserSpace> findallbyapidConroller(@RequestParam int apid) {
        AdvertiserSpace advertiserSpace = advertiserSpaceService.findbyapidService(apid);
        if (advertiserSpace != null) {
            return Result.success(advertiserSpace, "返回广告位成功!");
        } else {
            return Result.error("123", "返回广告位失败!");
        }
    }
    //撤销广告位
    @PostMapping("/quash")
    public Result<AdvertiserSpace> quashConroller(@RequestParam int apid) {
        AdvertiserSpace advertiserSpace = advertiserSpaceService.quashService(apid );
        if (advertiserSpace != null) {
            return Result.success(advertiserSpace, "返回广告位成功!");
        } else {
            return Result.error("123", "返回广告位失败!");
        }
    }



}
